Imports System.IO
Imports System.Data
Imports System.Data.SqlClient

Partial Class FanClubPictures
    Inherits System.Web.UI.Page

    Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    End Sub


    Sub PictureUploaded(ByVal sender As Object, ByVal e As PictureUpload.FileUploadEventArgs)

        ' add the image to the gallery table
        Dim conn As New SqlConnection(ConfigurationManager.ConnectionStrings("WroxUnited").ConnectionString)
        Dim cmd As New SqlCommand("INSERT INTO GALLERY(FixtureID, UploadedByMemberName, Notes, PictureURL) VALUES(@FixtureID, @UploadedByMemberName, @Notes, @PictureURL)", conn)

        cmd.Parameters.Add("@FixtureID", Data.SqlDbType.Int).Value = Convert.ToInt32(FixtureList1.SelectedValue)
        cmd.Parameters.Add("@UploadedByMemberName", Data.SqlDbType.VarChar, 50).Value = User.Identity.Name
        cmd.Parameters.Add("@Notes", Data.SqlDbType.VarChar, 255).Value = txtNotes.Text
        cmd.Parameters.Add("@PictureURL", Data.SqlDbType.VarChar, 50).Value = e.FileName

        conn.Open()
        cmd.ExecuteNonQuery()
        conn.Close()

        txtNotes.Text = ""
        DataList1.DataBind()

    End Sub

End Class
